#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 4e5 + 5;

int n, m, k;
int c[N], d[N];
struct Edge {
  int u, v, w;
  bool operator<(Edge o) const { return w < o.w; }
} e[N];

int head[N];
int ver[N], Next[N], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
int f[N], W[N], sz[N], num;
void init_f() {
  rep(i, 1, n * 2) f[i] = i;
  num = n;
}
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void merge(int x, int y, int w) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  ++num;
  f[fx] = num;
  f[fy] = num;
  add(num, fx);
  add(num, fy);
  W[num] = w;
}
ll ans = 0;
int a[N], b[N];
void dfs(int u) {
  if (c[u] == 1) a[u] += d[u];
  if (c[u] == 2) b[u] += d[u];
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    dfs(v);
    a[u] += a[v], b[u] += b[v];
  }
  int x = min(a[u], b[u]);
  a[u] -= x, b[u] -= x;
  ans += 1ll * x * W[u];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  rep(i, 1, m) cin >> e[i].u >> e[i].v >> e[i].w;
  rep(i, 1, k) {
    int x;
    cin >> x;
    c[x] = 1, d[x]++;
  }
  rep(i, 1, k) {
    int x;
    cin >> x;
    c[x] = 2, d[x]++;
  }
  sort(e + 1, e + m + 1);
  init_f();
  rep(i, 1, m) merge(e[i].u, e[i].v, e[i].w);
  int root = find(1);
  dfs(root);
  cout << ans;
  return 0;
}